package com.beamfield.controller.manage;

import com.beamfield.common.ApiResult;
import com.beamfield.controller.common.BaseController;
import com.beamfield.enums.HttpResultEnum;
import com.beamfield.service.manage.sys.BimIndexService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Zephyr
 * @Description:
 * @Date 2018/8/13
 */
@Controller
@RequestMapping("/cms")
public class BimIndexController extends BaseController {

    final private BimIndexService bimIndexService;
    @Autowired
    public BimIndexController(BimIndexService bimIndexService){
        this.bimIndexService = bimIndexService;
    }
    @RequestMapping(value = "/bim_index")
    public ModelAndView bimIndex(){
        return new ModelAndView();
    }
    @RequestMapping(value = "/beam_select")
    public ModelAndView beamSelect(){
        return new ModelAndView();
    }

    /**
     * 获取bim首页统计信息
     * @param request
     * @return
     */
    @RequestMapping(value = "/getBimStatistics")
    @ResponseBody
    public ApiResult getBimStatistics(HttpServletRequest request){
        Long beamId = super.getBeamId(request);
        try{
            return bimIndexService.getBimStatistics(beamId);
        }catch (Exception e){
            e.printStackTrace();
            return new ApiResult(HttpResultEnum.EXCEPTION.getCode(), HttpResultEnum.EXCEPTION.getMessage());
        }
    }
}
